
************************************************************************************************************************************************
************************************************************************************************************************************************
***This file corresponds to the analysis of Latino adults in the experiment reported in Perez, Vicuna, and Ramos (2022) in Research & Politics***
************************************************************************************************************************************************
************************************************************************************************************************************************


/*code demographics*/

**keep latinos

gen latino=0
recode latino(0=1) if Q1==3
drop if latino==0
tab latino

**age

gen age=Q5
recode age(1=18)(2=19)(3=20)(4=21)(5=22)(6=23)(7=24)(8=25)(9=26)(10=27)(11=28)(12=29)(13=30)(14=31)(15=32)(16=33)(17=34)(18=35)(19=36)(20=37)(21=38)(22=39)(23=40)(24=41)(25=42)(26=43)(27=44)(28=45)(29=46)(30=47)(31=48)(32=49)(33=50)(34=51)(35=52)(36=53)(37=54)(38=55)(39=56)(40=57)(41=58)(42=59)(43=60)(44=61)(45=62)(46=63)(47=64)(48=65)(49=66)(50=67)(51=68)(52=69)(53=70)(54=71)(55=72)(56=73)(57=74)(58=75)(59=76)(60=77)(61=78)
summ age
summ age, detail

**gender

gen female=0
recode female(0=1) if Q6==1 
tab female

**ideology

gen liberal=Q8
summ liberal


/*code experimental treatments*/

encode m1, gen(treats)

gen inferior=0
recode inferior(0=1) if treats==2

gen american=0
recode american(0=1) if treats==3

tab inferior american
tab inferior
tab american

**generate comparison of american treatment to conrol only

gen american2=.
recode american2(.=1) if american==1
recode american2(.=0) if treats==1
tab american2


/*randomization and balance checks*/

ttest age, by(american2)
ttest female, by (american2)  
ttest liberal, by (american2)

reg american2 age female liberal
test age female liberal


/*code manipulation checks*/

**control manipulation check

drop if Q14==2

**inferior check

drop if Q15==2

**american check

drop if Q16==2


/*code mediator - solidarity with poc*/

gen poc1=Q17
summ poc1

gen poc2=Q18
recode poc2(1=5)(2=4)(3=3)(4=2)(5=1)
summ poc2

alpha poc1 poc2
pwcorr poc1 poc2, sig

gen pocsolid1=(poc1+poc2)/2
summ pocsolid1

gen pocsolid=(pocsolid1-1)/4
summ pocsolid


/*code outcomes*/

gen borderpat1=Q19
recode borderpat1(1=5)(2=4)(3=3)(4=2)(5=1)
summ borderpat1

gen daca1=Q20
summ daca1

gen pathway1=Q21
summ pathway1

alpha borderpat1 daca1 pathway1, std
pwcorr borderpat1 daca1 pathway1, sig


gen hatecrime1=Q22
summ hatecrime1

gen blm1=Q23
recode blm1(1=5)(2=4)(3=3)(4=2)(5=1)
summ blm1

gen repar1=Q23
summ repar1

pwcorr hatecrime1 blm1 repar1 

**exclude repar1 from further analysis


/*recode variables to 0-1 range*/

gen hatecrime=(hatecrime1-1)/4
gen blm=(blm1-1)/4

gen borderpat=(borderpat1-1)/4
gen daca=(daca1-1)/4
gen pathway=(pathway1-1)/4

summ hatecrime blm borderpat daca pathway

**create policy scales

gen prolat=(borderpat+daca+pathway)/3
summ prolat

gen problk=(blm+hatecrime)/2
summ problk

/*mediation analysis*/

**table 1

reg pocsolid american2

medeff (regress pocsolid american2) (regress hatecrime american2 pocsolid), mediate(pocsolid) treat(american2) sims(1000) seed(1)
medeff (regress pocsolid american2) (regress blm american2 pocsolid), mediate(pocsolid) treat(american2) sims(1000) seed(1)
medeff (regress pocsolid american2) (regress problk american2 pocsolid), mediate(pocsolid) treat(american2) sims(1000) seed(1)

medeff (regress pocsolid american2) (regress borderpat american2 pocsolid), mediate(pocsolid) treat(american2) sims(1000) seed(1)
medeff (regress pocsolid american2) (regress pathway american2 pocsolid), mediate(pocsolid) treat(american2) sims(1000) seed(1)
medeff (regress pocsolid american2) (regress daca american2 pocsolid), mediate(pocsolid) treat(american2) sims(1000) seed(1)
medeff (regress pocsolid american2) (regress prolat american2 pocsolid), mediate(pocsolid) treat(american2) sims(1000) seed(1)


**sensitivity analysis

medsens (regress pocsolid american2) (regress problk american2 pocsolid), mediate(pocsolid) treat(american2) sims(1000) eps(.01)


/*revisions for referees at Research & Politics during peer review*/

**robust to inclusion of both experimental conditions

reg pocsolid inferior american
reg problk inferior american
reg prolat inferior american

**generate mexican and puerto rican sample to analyze heterogenous treatment effects

tab Q2
tab Q2, nolabel

gen mexican=.
recode mexican(.=0) if Q2==18
recode mexican(.=1) if Q2==13
tab mexican

tab mexican american2

reg pocsolid american2 mexican
gen mexam=(mexican*american2)

reg pocsolid american2 mexican mexam, robust
test mexican mexam



